﻿namespace GSC.WebControls
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI.Design;
    using System.Web.UI.Design.WebControls;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.ComponentModel.Design;
    using System.Web.UI.HtmlControls;
    /// <summary>
    /// 左边垂直菜单控件设计器。
    /// </summary>
    /// <remarks>左边垂直菜单控件设计器。</remarks>
    internal sealed class BackgroundCenterLeftMenuControlDesigner : DataBoundControlDesigner
    {
        BackgroundCenterLeftMenuControl _CenterLeftMenu;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Component"></param>
        public override void Initialize(IComponent Component)
        {
            base.Initialize(Component);
            this._CenterLeftMenu = (BackgroundCenterLeftMenuControl)Component;
        }
        protected override void PostFilterProperties(System.Collections.IDictionary properties)
        {
            base.PostFilterProperties(properties);
            if (string.IsNullOrEmpty(this.DataSourceID))
            {
                if (!properties.Contains("Titles"))
                {
                    PropertyDescriptor pdItems = TypeDescriptor.CreateProperty(
                        typeof(BackgroundCenterLeftMenuControlDesigner),
                        "Titles",
                        typeof(BackgroundCenterLeftMenuTitleControlCollection),
                        new Attribute[] { new DesignOnlyAttribute(true) });
                    properties.Add("Titles", pdItems);
                }
            }
            else
            {
                if (properties.Contains("Titles"))
                    properties.Remove("Titles");
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string GetDesignTimeHtml()
        {
            StringWriter sw = null;
            HtmlTextWriter tw = null;
            try
            {
                //
                if (GetDesignTimeDataSource() != null && !string.IsNullOrEmpty(this._CenterLeftMenu.DataSourceID))
                {
                    _CenterLeftMenu.Titles.Clear();
                    //键值
                    string _DataTextField = _CenterLeftMenu.DataTextField;
                    string _DataCommandArgumentField = _CenterLeftMenu.DataCommandArgumentField;
                    string _DataCommandNameField = _CenterLeftMenu.DataCommandNameField;
                    string _DataToolTipField = _CenterLeftMenu.DataToolTipField;
                    string _DataParentField = _CenterLeftMenu.DataParentField;
                    string _DataPrimaryKeyField = _CenterLeftMenu.DataValueField;
                    int parentID = 0;
                    int primaryKey = 0;
                    //
                    foreach (object dataItem in this.GetDesignTimeDataSource())
                    {
                        //获取父级ID。
                        if (!string.IsNullOrEmpty(_DataParentField))
                        {
                            parentID = (int)DataBinder.GetPropertyValue(dataItem, _DataParentField);
                            //读取父级标题。
                            if (parentID.Equals(0))
                            {
                                //获取主键ID。
                                if (!string.IsNullOrEmpty(_DataPrimaryKeyField))
                                {
                                    primaryKey = (int)DataBinder.GetPropertyValue(dataItem, _DataPrimaryKeyField);
                                }
                                BackgroundCenterLeftMenuTitleControl t = new BackgroundCenterLeftMenuTitleControl();
                                if (!string.IsNullOrEmpty(_DataTextField))
                                {
                                    t.Text = DataBinder.GetPropertyValue(dataItem, _DataTextField, null);
                                }
                                //
                                if (!string.IsNullOrEmpty(_DataCommandArgumentField))
                                {
                                    t.CommandArgument = DataBinder.GetPropertyValue(dataItem, _DataCommandArgumentField, null);
                                }
                                //
                                if (!string.IsNullOrEmpty(_DataCommandNameField))
                                {
                                    t.CommandName = DataBinder.GetPropertyValue(dataItem, _DataCommandNameField, null);
                                }
                                //
                                if (!string.IsNullOrEmpty(_DataToolTipField))
                                {
                                    t.ToolTip = DataBinder.GetPropertyValue(dataItem, _DataToolTipField, null);
                                }
                                _CenterLeftMenu.Titles.Add(t);
                                foreach (object cdataItem in this.GetDesignTimeDataSource())
                                {
                                    //获取父级ID。
                                    parentID = (int)DataBinder.GetPropertyValue(cdataItem, _DataParentField);
                                    if (parentID.Equals(primaryKey))
                                    {
                                        BackgroundCenterLeftMenuButtonControl b = new BackgroundCenterLeftMenuButtonControl();
                                        if (!string.IsNullOrEmpty(_DataTextField))
                                        {
                                            b.Text = DataBinder.GetPropertyValue(cdataItem, _DataTextField, null);
                                        }
                                        //
                                        if (!string.IsNullOrEmpty(_DataCommandArgumentField))
                                        {
                                            b.CommandArgument = DataBinder.GetPropertyValue(cdataItem, _DataCommandArgumentField, null);
                                        }
                                        //
                                        if (!string.IsNullOrEmpty(_DataCommandNameField))
                                        {
                                            b.CommandName = DataBinder.GetPropertyValue(cdataItem, _DataCommandNameField, null);
                                        }
                                        //
                                        if (!string.IsNullOrEmpty(_DataToolTipField))
                                        {
                                            b.ToolTip = DataBinder.GetPropertyValue(cdataItem, _DataToolTipField, null);
                                        }
                                        t.Buttons.Add(b);
                                    }
                                }
                            }
                        }
                    }
                }
                ((ICompositeControlDesignerAccessor)this._CenterLeftMenu).RecreateChildControls();
                int ti = 0;
                int i = 0;
                foreach (BackgroundCenterLeftMenuTitleControl item in this._CenterLeftMenu.Titles)
                {
                    ((ICompositeControlDesignerAccessor)item).RecreateChildControls();
                    item.Attributes[DesignerRegion.DesignerRegionAttributeName] = ti.ToString();
                    ti++;
                    foreach (BackgroundCenterLeftMenuButtonControl citem in item.Buttons)
                    {
                        ((ICompositeControlDesignerAccessor)citem).RecreateChildControls();
                        citem.Attributes[DesignerRegion.DesignerRegionAttributeName] = i.ToString();
                        i++;
                    }
                }
                //
                if (this._CenterLeftMenu.Titles.Count > 0)
                {
                    Panel panel = new Panel();
                    panel.Style["overflow"] = "hidden";
                    panel.Width = this._CenterLeftMenu.Width;
                    panel.Height = this._CenterLeftMenu.Height;
                    //
                    foreach (BackgroundCenterLeftMenuTitleControl item in this._CenterLeftMenu.Titles)
                    {
                        //
                        Panel title = new Panel();
                        panel.Controls.Add(title);
                        title.Style["overflow"] = "hidden";
                        title.Width = this._CenterLeftMenu.Width;
                        //
                        Panel titleContainer = new Panel();
                        titleContainer.Style["background-position"] = "left top";
                        titleContainer.Width = this._CenterLeftMenu.Width;
                        titleContainer.Height = this._CenterLeftMenu.TitleHeight;
                        if (string.IsNullOrEmpty(this._CenterLeftMenu.TitleBackImage))
                            titleContainer.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("TitleBg.gif")) + ")";
                        else
                            titleContainer.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage) + ")";
                        title.Controls.Add(titleContainer);
                        //
                        Panel iconContainer = new Panel();
                        iconContainer.Style["float"] = "left";
                        iconContainer.Style["padding-top"] = "5px";
                        iconContainer.Style["padding-left"] = "1px";
                        iconContainer.Style["font-size"] = "0px";
                        iconContainer.Style["overflow"] = "hidden";
                        title.Controls.Add(iconContainer);
                        System.Web.UI.WebControls.Image icon = new System.Web.UI.WebControls.Image();

                        iconContainer.Controls.Add(icon);
                        titleContainer.Controls.Add(iconContainer);
                        //
                        Panel buttonContainer = new Panel();
                        buttonContainer.Style["float"] = "left";
                        buttonContainer.Style["padding-top"] = "5px";
                        buttonContainer.Style["padding-left"] = "0px";
                        buttonContainer.Style["font-size"] = "0px";
                        buttonContainer.Style["overflow"] = "hidden";
                        //
                        LinkButton titleButton = new LinkButton();
                        titleButton.Text = item.Text;
                        titleButton.ForeColor = item.ForeColor;
                        titleButton.Font.CopyFrom(item.Font);
                        titleButton.CommandName = item.CommandName;
                        titleButton.CommandArgument = item.CommandArgument;
                        buttonContainer.Controls.Add(titleButton);
                        //
                        titleContainer.Controls.Add(buttonContainer);
                        //
                        Panel contentContainer = new Panel();
                        if (item.IsExpanded)
                        {
                            if (this._CenterLeftMenu.ExpandedIcon == string.Empty)
                                icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Expanded.gif"));
                            else
                                icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ExpandedIcon);
                        }
                        else
                        {
                            if (this._CenterLeftMenu.CollapseIcon == string.Empty)
                                icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Collapse.gif"));
                            else
                                icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.CollapseIcon);
                            //
                            contentContainer.Style["display"] = "none";
                        }
                        //
            
                        if (!this._CenterLeftMenu.TitleTextWidth.IsEmpty)
                        {
                            buttonContainer.Style["white-space"] = "nowrap";
                            buttonContainer.Style["text-overflow"] = "ellipsis";
                            buttonContainer.Style["-o-text-overflow"] = "ellipsis";
                            buttonContainer.Style["width"] = this._CenterLeftMenu.TitleTextWidth.ToString();
                        }
                        //
                        contentContainer.Width = item.Width;
                        title.Controls.Add(contentContainer);
                        foreach (BackgroundCenterLeftMenuButtonControl citem in item.Buttons)
                        {
                            Panel buttons = new Panel();
                            buttons.Style["overflow"] = "hidden";
                            buttons.Style["background-position"] = "left top";
                            buttons.Style["white-space"] = "nowrap";
                            buttons.Style["text-overflow"] = "ellipsis";
                            buttons.Height = this._CenterLeftMenu.ButtonHeight;
                            buttons.Width = this._CenterLeftMenu.Width;
                            if (citem.IsSelected)
                                if (string.IsNullOrEmpty(this._CenterLeftMenu.SelectedButtonBackImage))
                                    buttons.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("SelectedButtonBg.gif")) + ")";
                                else
                                    buttons.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.SelectedButtonBackImage) + ")";
                            else
                                if (string.IsNullOrEmpty(this._CenterLeftMenu.ButtonBackImage))
                                    buttons.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("ButtonBg.gif")) + ")";
                                else
                                    buttons.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ButtonBackImage) + ")";
                            contentContainer.Controls.Add(buttons);
                            //
                            Panel buttonsContainer = new Panel();
                            buttonsContainer.Height = this._CenterLeftMenu.ButtonHeight;
                            buttonsContainer.Width = this._CenterLeftMenu.Width;
                            buttonsContainer.Style["overflow"] = "hidden";
                            buttonsContainer.Style["font-size"] = "0px";
                            buttonsContainer.Style["padding-top"] = "5px";
                            buttonsContainer.Style["padding-left"] = "4px";
                            buttons.Controls.Add(buttonsContainer);
                            //
                            LinkButton kinkButtons = new LinkButton();
                            kinkButtons.Text = citem.Text;
                            kinkButtons.ForeColor = citem.ForeColor;
                            kinkButtons.Font.CopyFrom(citem.Font);
                            buttonsContainer.Controls.Add(kinkButtons);
                        }
                    }
                    //
                    Panel end = new Panel();
                    if (this._CenterLeftMenu.ShowEnd)
                    {
                        end.Visible = true;
                        end.Style["background-position"] = "left top";
                        end.Width = this._CenterLeftMenu.Width;
                        end.Height = this._CenterLeftMenu.EndHeight;
                        if (string.IsNullOrEmpty(this._CenterLeftMenu.TitleBackImage))
                            end.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("EndBg.gif")) + ")";
                        else
                            end.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage) + ")";
                    }
                    else
                    {
                        end.Visible = false;
                    }
                    panel.Controls.Add(end);
                    //
                    sw = new StringWriter();
                    tw = new HtmlTextWriter(sw);
                    panel.RenderControl(tw);
                    return sw.ToString();
                    /*
                    //this._CenterLeftMenu.Style["height"] = "auto";
                    this._CenterLeftMenu.Style["overflow"] = "hidden";
                    foreach (CenterLeftMenuTitle item in this._CenterLeftMenu.Titles)
                    {
                        //
                        item.Button.Text = item.Text;
                        item.Button.ForeColor = item.ForeColor;
                        item.Button.Font.CopyFrom(item.Font);
                        item.Button.CommandName = item.CommandName;
                        item.Button.CommandArgument = item.CommandArgument;
                        //
                        item.Style["overflow"] = "hidden";
                        item.Width = this._CenterLeftMenu.Width;
                        //
                        item.TitleContainer.Style["background-position"] = "left top";
                        item.TitleContainer.Width = this._CenterLeftMenu.Width;
                        item.TitleContainer.Height = this._CenterLeftMenu.TitleHeight;
                        if (string.IsNullOrEmpty(this._CenterLeftMenu.TitleBackImage))
                            item.TitleContainer.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("TitleBg.gif")) + ")";
                        else
                            item.TitleContainer.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage) + ")";
                        //
                        item.IconContainer.Style["float"] = "_left";
                        item.IconContainer.Style["padding-top"] = "5px";
                        item.IconContainer.Style["padding-left"] = "1px";
                        item.IconContainer.Style["font-size"] = "0px";
                        item.IconContainer.Style["overflow"] = "hidden";
                        //
                        if (item.IsExpanded)
                        {
                            if (this._CenterLeftMenu.ExpandedIcon == string.Empty)
                                item.Icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Expanded.gif"));
                            else
                                item.Icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ExpandedIcon);
                            //
                            //item.ContentContainer.Style["display"] = "";
                        }
                        else
                        {
                            if (this._CenterLeftMenu.CollapseIcon == string.Empty)
                                item.Icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Collapse.gif"));
                            else
                                item.Icon.ImageUrl = this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.CollapseIcon);
                            //
                            item.ContentContainer.Style["display"] = "none";
                        }
                        //
                        item.ButtonContainer.Style["float"] = "_left";
                        item.ButtonContainer.Style["padding-top"] = "5px";
                        item.ButtonContainer.Style["padding-left"] = "0px";
                        item.ButtonContainer.Style["font-size"] = "0px";
                        item.ButtonContainer.Style["overflow"] = "hidden";
                        if (!this._CenterLeftMenu.TitleTextWidth.IsEmpty)
                        {
                            item.ButtonContainer.Style["white-space"] = "nowrap";
                            item.ButtonContainer.Style["text-overflow"] = "ellipsis";
                            item.ButtonContainer.Style["-o-text-overflow"] = "ellipsis";
                            item.ButtonContainer.Style["width"] = this._CenterLeftMenu.TitleTextWidth.ToString();
                        }
                        //
                        //item.Button.Style["font-size"] = "14px";
                        //item.Button.Style["font-weight"] = "bold";
                        //
                        item.ContentContainer.Width = item.Width;
                        foreach (CenterLeftMenuButton citem in item.Buttons)
                        {
                            //citem.Button.Text = citem.Text;
                            //citem.Button.ForeColor = citem.ForeColor;
                            //citem.Button.Font.CopyFrom(citem.Font);
                            //
                            citem.Style["overflow"] = "hidden";
                            citem.Style["background-position"] = "left top";
                            citem.Style["white-space"] = "nowrap";
                            citem.Style["text-overflow"] = "ellipsis";
                            citem.Height = this._CenterLeftMenu.ButtonHeight;
                            citem.Width = this._CenterLeftMenu.Width;
                            if (citem.IsSelected)
                                if (string.IsNullOrEmpty(this._CenterLeftMenu.SelectedButtonBackImage))
                                    citem.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("SelectedButtonBg.gif")) + ")";
                                else
                                    citem.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.SelectedButtonBackImage) + ")";
                            else
                                if (string.IsNullOrEmpty(this._CenterLeftMenu.ButtonBackImage))
                                    citem.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("ButtonBg.gif")) + ")";
                                else
                                    citem.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ButtonBackImage) + ")";
                            //
                            citem.ButtonContainer.Height = this._CenterLeftMenu.ButtonHeight;
                            citem.ButtonContainer.Width = this._CenterLeftMenu.Width;
                            citem.ButtonContainer.Style["overflow"] = "hidden";
                            citem.ButtonContainer.Style["font-size"] = "0px";
                            citem.ButtonContainer.Style["padding-top"] = "5px";
                            citem.ButtonContainer.Style["padding-left"] = "4px";
                            //
                        }
                    }
                    //
                    if (this._CenterLeftMenu.ShowEnd)
                    {
                        this._CenterLeftMenu.End.Visible = true;
                        this._CenterLeftMenu.End.Style["background-position"] = "left top";
                        this._CenterLeftMenu.End.Width = this._CenterLeftMenu.Width;
                        this._CenterLeftMenu.End.Height = this._CenterLeftMenu.EndHeight;
                        if (string.IsNullOrEmpty(this._CenterLeftMenu.TitleBackImage))
                            this._CenterLeftMenu.End.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("EndBg.gif")) + ")";
                        else
                            this._CenterLeftMenu.End.Style["background-image"] = "url(" + this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage) + ")";
                    }
                    else
                    {
                        this._CenterLeftMenu.End.Visible = false;
                    }
                    */
                }
                else
                {
                    System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Properties.Resources));
                    return "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.Height.ToString() + " ;background-color: " + (this._CenterLeftMenu.BackColor.IsEmpty ? "#FFFFFF" : System.Drawing.ColorTranslator.ToHtml(this._CenterLeftMenu.BackColor)) + ";'>" +
                           "<div style='overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.TitleHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.TitleBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("TitleBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._CenterLeftMenu.CollapseIcon == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Collapse.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.CollapseIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                        //
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.TitleHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.TitleBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("TitleBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._CenterLeftMenu.CollapseIcon == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Collapse.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.CollapseIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                        //
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.TitleHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.TitleBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("TitleBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._CenterLeftMenu.ExpandedIcon == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Expanded.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ExpandedIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                        //演示按钮
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.ButtonBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("ButtonBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoButton") +
                           "</div>" +
                           "</div>" +
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.ButtonBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("ButtonBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoButton") +
                           "</div>" +
                           "</div>" +
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.SelectedButtonBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("SelectedButtonBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.SelectedButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoSelectedButton") +
                           "</div>" +
                           "</div>" +
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.ButtonBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("ButtonBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.ButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.ButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoButton") +
                           "</div>" +
                           "</div>" +
                        //
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._CenterLeftMenu.Width.ToString() + " ;height:" + this._CenterLeftMenu.TitleHeight.ToString() + "; background-image:url(" + (this._CenterLeftMenu.TitleBackImage == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("TitleBg.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.TitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._CenterLeftMenu.CollapseIcon == string.Empty ? this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.GetWebResourceUrl("Collapse.gif")) : this._CenterLeftMenu.ResolveClientUrl(this._CenterLeftMenu.CollapseIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                           "</div>";
                }
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
        public override void OnComponentChanging(object sender, ComponentChangingEventArgs ce)
        {
            base.OnComponentChanging(sender, ce);
        }
        public override void OnComponentChanged(object sender, ComponentChangedEventArgs ce)
        {
            base.OnComponentChanged(sender, ce);
            /*
            switch (ce.Member.Name)
            {
                case "MultiLine":
                    if (!(bool)ce.NewValue)
                    {
                        bool ise = true;
                        foreach (CenterLeftMenuTitle item in this._LeftMenu.Titles)
                        {
                            if (ise && item.IsExpanded)
                            {
                                ise = false;
                            }
                            else
                            {
                                item.IsExpanded = false;
                            }
                        }
                    }
                    break;
            }
             */ 
        }
        /*
        public override string GetDesignTimeHtml(DesignerRegionCollection regions)
        {
            for (int i = 0; i < this._LeftMenu.Titles.Count; i++)
            {
                DesignerRegion dr = new DesignerRegion(this, "Title|" + i.ToString());
                regions.Add(dr);
                for (int n = 0; n < this._LeftMenu.Titles[i].Buttons.Count; n++)
                {
                    dr = new DesignerRegion(this, "Button|" + n.ToString());
                    regions.Add(dr);
                }
            }
            return base.GetDesignTimeHtml(regions);
        }
        protected override void OnClick(DesignerRegionMouseEventArgs e)
        {
            int i = 0;
            string[] d = e.Region.Name.Split(new char[] { '|' });
            switch (d[0])
            {
                case "Title":

                    break;
                case "Button":
                    foreach (CenterLeftMenuTitle item in this._LeftMenu.Titles)
                    {
                        foreach (CenterLeftMenuButton citem in item.Buttons)
                        {
                            if (i.ToString().Equals(d[1]))
                            {
                                citem.IsSelected = true;
                            }
                            else
                            {
                                citem.IsSelected = false;
                            }
                            i++;
                        }
                    }
                    break;
            }
            base.OnClick(e);
        }
         */ 
    }
}